home *** CD-ROM | disk | FTP | other *** search
- package symantec.itools.db.awt;
-
- import java.awt.Checkbox;
- import java.awt.CheckboxGroup;
- import java.awt.Component;
- import java.awt.Event;
- import java.io.IOException;
- import symantec.itools.db.pro.ProjBinder;
- import symantec.itools.db.pro.ProjLink;
- import symantec.itools.db.pro.RelationView;
- import symjava.sql.SQLException;
-
- public class RadioButton extends Checkbox implements ProjLink {
- private ProjBinder m_ProjBinder;
- private String m_Data;
- private String m_Input;
- private int m_treatBlankAs;
- private boolean m_DynamicUpdate = false;
-
- public RadioButton() {
- super.setLabel("<dbAWARE RadioButton>");
- }
-
- public RadioButton(String label, RadioBox rb, boolean state) {
- super(label, rb, state);
- this.setBinding(rb.getRelView(), rb.getProjection());
- }
-
- public void setTreatBlankAs(String blank) {
- if ((new String(blank)).toUpperCase().equals("DEFAULT")) {
- this.m_treatBlankAs = 0;
- } else if ((new String(blank)).toUpperCase().equals("NULL")) {
- this.m_treatBlankAs = 1;
- } else {
- if ((new String(blank)).toUpperCase().equals("EMPTY")) {
- this.m_treatBlankAs = 2;
- }
-
- }
- }
-
- public void setBinding(RelationView relView, String projection) {
- try {
- int projectionNumber = relView.findProjByName(projection);
- relView.bindProj(projectionNumber, this);
- } catch (SQLException Ex) {
- this.raiseException("SQLException from RadioButton.setBinding: " + ((Throwable)Ex).getMessage());
- }
- }
-
- public void init(ProjBinder binder) {
- this.m_ProjBinder = binder;
- this.setEditable(this.m_ProjBinder);
- }
-
- public void notifyDataChange(ProjBinder binder) {
- if (binder != null) {
- this.m_ProjBinder = binder;
- }
-
- String sLabel = new String(((Checkbox)this).getLabel());
- new String();
-
- try {
- if (binder.isReadable() && !binder.isNull()) {
- String data = binder.getStringValue();
- if (sLabel.compareTo(data) == 0) {
- ((Checkbox)this).setState(true);
- }
- }
- } catch (SQLException Ex) {
- this.raiseException("SQLException from RadioButton.notifyDataChange: " + ((Throwable)Ex).getMessage());
- } catch (IOException Ex) {
- this.raiseException("IOException from RadioButton.notifyDataChange: " + ((Throwable)Ex).getMessage());
- }
-
- this.setEditable(this.m_ProjBinder);
- }
-
- public boolean lostFocus(Event evt, Object what) {
- this.notifyStateChange();
- return super.lostFocus(evt, what);
- }
-
- public boolean notifySetData(ProjBinder binder) {
- return this.notifyStateChange();
- }
-
- boolean notifyStateChange() {
- CheckboxGroup rbg = ((Checkbox)this).getCheckboxGroup();
- if (rbg.getCurrent() == this) {
- try {
- if (this.m_ProjBinder != null && this.m_ProjBinder.isWritable()) {
- this.m_ProjBinder.setValueFromString(((Checkbox)this).getLabel(), 0, this.m_treatBlankAs);
- }
- } catch (SQLException Ex) {
- System.out.println("SQLException from TextField.notifyInputChange.setString: " + ((Throwable)Ex).getMessage());
- return false;
- } catch (IOException Ex) {
- System.out.println("IOException from TextField.notifyInputChange.setString: " + ((Throwable)Ex).getMessage());
- return false;
- }
- }
-
- return true;
- }
-
- public boolean handleEvent(Event evt) {
- this.notifyStateChange();
- return super.handleEvent(evt);
- }
-
- void setEditable(ProjBinder binder) {
- ((Component)this).disable();
-
- try {
- if (binder != null) {
- RelationView rv = binder.getRelationView();
- if (rv != null && rv.getCurrentRecordState() != 105) {
- ((Component)this).enable();
- return;
- }
- }
- } catch (SQLException Ex) {
- System.out.println(((Throwable)Ex).getMessage());
- }
-
- }
-
- void raiseException(String text) {
- System.out.println(text);
- }
-
- public void setDynamicUpdate(boolean update) {
- this.m_DynamicUpdate = update;
- }
- }
-